package com.cloud.translation.Adapter;

import android.widget.PopupWindow;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;

import com.cloud.translation.BaseAdapter.BaseRecyclerAdapter;
import com.cloud.translation.BaseAdapter.BaseRecyclerHolder;
import com.cloud.translation.R;

public class HomeAdapter extends BaseRecyclerAdapter<Language> {

    private TextView textView;

    private PopupWindow popupWindow;

    private int number=100;

    public HomeAdapter(FragmentActivity activity, TextView textView, PopupWindow popupWindow) {
        super(activity, R.layout.item_text);
        this.textView = textView;
        this.popupWindow=popupWindow;
    }

    @Override
    protected void convert(BaseRecyclerHolder holder, Language data) {
        holder.setText(R.id.text, data.getName());
        holder.itemView.setOnClickListener(l -> {
            number=items.indexOf(data);
            textView.setText(data.getName());
            popupWindow.dismiss();
        });
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }
}
